import request from '@/utils/request'

// 账号密码登录
export const userAccountLogin = ({ account, password }) => {
  return request('/login', 'post', { password, account })
}

// 发送验证码
export const userMobileLoginMsg = (mobile) => {
  return request('/login/code', 'get', { mobile })
}

// 验证码登录
export const userMobileLogin = ({ mobile, code }) => {
  return request('/login/code', 'post', { mobile, code })
}

// qq登录 unionId:第三方标识
export const userLoginQQ = ({ unionId, source = 1 }) => {
  return request('/login/social', 'post', { unionId, source })
}

// QQ登录时绑定手机号的验证码
export const userQQBandCode = mobile => {
  return request('/login/social/code', 'get', { mobile })
}

// QQ与手机绑定
export const userQQBindLogin = ({ unionId, mobile, code }) => {
  return request('/login/social/bind', 'post', { unionId, mobile, code })
}

// 校验用户名唯一
export const userNameCheck = account => {
  return request('/register/check', 'get', { account })
}

// 完善信息获取验证码
export const userQQPatchCode = mobile => {
  return request('/register/code', 'get', { mobile })
}

// 提交完善信息
export const userLogin = ({ unionId, mobile, code, account, password }) => {
  return request(`/login/social/${unionId}/complement`, 'get', { unionId, mobile, code, account, password })
}
